WordPress announced that the upcoming WordPress 5.4 may include image lazy-loading by default. This feature will enable the "loading" HTML attribute on all IMG elements, eliminating the need for WordPress publishers to rely on JavaScript or third-party plugins for lazy-loading their images.
Lazy-loading
The lazy-loading HTML attribute instructs a browser to either wait before downloading an image or download it immediately, with no need for JavaScript.
There are three kinds of lazy-loading attributes, but only two are significant:
- Lazy
- Eager
By default, WordPress 5.4 will enable the lazy attribute, which means the browser will wait until the user’s viewport is within a certain distance before downloading the image. This behavior will enhance the user experience on WordPress sites. The "eager" attribute, on the other hand, prompts the browser to immediately download the image.
WordPress 5.4 Release Date
WordPress 5.4 is currently scheduled for release on March 31, 2020. This date may change depending on the readiness of the release, but WordPress has a strong track record of meeting its deadlines.
According to the WordPress announcement:
"The implementation seeks to enable lazy-loading images by default, providing the loading attribute with value lazy on the following img tags:
Images in post content
Images in post excerpts
Images in comments
Images in text widget content
Individual images rendered via wp_get_attachment_image()
Avatar images rendered via get_avatar()Note that loading=”lazy” will only be added if the respective tag does not yet include a loading attribute. In other words, to prevent an image from being lazy-loaded, it is recommended to specify loading=”eager”."
WordPress comments indicate that these lazy-loading attributes will be easy to remove if necessary. This adaptability is important in case future browsers begin lazy-loading all images by default, without needing a loading attribute.
Google has stated that there are plans to automatically enable lazy-loading for all images when a browser is in Lite mode (formerly known as Data Saver mode).
Test Drive WordPress Lazy-Loading
The WordPress team has released a lazy-loading plugin for testing purposes. Publishers who wish to test and provide feedback are encouraged to download the plugin and give it a try.
For more details, refer to the official WordPress announcement:
Lazy-Loading Images in WordPress Core